//
//  ZTXSelecteBankView.m
//  NtoccDriverNew
//
//  Created by 张天兴 on 2024/8/26.
//  Copyright © 2024 GCY. All rights reserved.
//

#import "ZTXSelecteBankView.h"




@implementation ZTXSelecteBankView



- (instancetype)initWithFrame:(CGRect)frame bardCad:(NSString *)cad isBangDing:(NSString *)bangding{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.cadStr = cad;
        self.bangdingStr = bangding;
        [self initUI];
        
    }
    return self;
}
- (void)initUI{
    self.isPuFaBack = @"1";
    [self addSubview:self.bottomBgView];
}
- (UIView *)bottomBgView{
    if (!_bottomBgView) {
        self.bottomBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH)];
        self.bottomBgView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
        [self.bottomBgView addSubview:self.bgView];
    }
    return _bottomBgView;
}
- (UIView *)bgView{
    if (!_bgView) {
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenH - MenuBarHeight - 306, ScreenW, 306)];
        self.bgView.backgroundColor = CJRGBColor(245, 248, 254);
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 10;
        [self.bgView addSubview:self.topView];
        [self.bgView addSubview:self.puFView];
        [self.bgView addSubview:self.kuaiQView];
        [self.bgView addSubview:self.BangDingButton];
    }
    return _bgView;
}

- (UIView *)topView{
    if (!_topView) {
        self.topView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, ScreenW - 20, 44)];
        self.topView.backgroundColor = [UIColor whiteColor];
        self.topView.layer.masksToBounds = YES;
        self.topView.layer.cornerRadius = 10;
        self.topImagView = [[UIImageView alloc] initWithFrame:CGRectMake(11, 11, 22, 22)];
        if ([self.bangdingStr isEqualToString:@"1"]) {
            self.topImagView.image = [UIImage imageNamed:@"selectedBarkTop"];
        }else{
            self.topImagView.image = [UIImage imageNamed:@"jiebangBarkTop"];
        }
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.topImagView.frame) + 10, 0, 200, 44)];
        titleLabel.text = @"选择银行卡要绑定的账户";
        self.cententButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.cententButton.frame = CGRectMake(ScreenW - 10 - 50, 7, 32, 32);
        [self.cententButton setBackgroundImage:[UIImage imageNamed:@"Instagram"] forState:(UIControlStateNormal)];
        [self.topView addSubview:self.topImagView];
        [self.topView addSubview:titleLabel];
        [self.topView addSubview:self.cententButton];
    }
    return _topView;
}
- (UIView *)puFView{
    if (!_puFView) {
        self.puFView = [[UIView alloc] initWithFrame:CGRectMake(15,CGRectGetMaxY(self.topView.frame) + 10, ScreenW - 30, 44)];
        self.puFView.backgroundColor = [UIColor whiteColor];
        self.puFView.layer.masksToBounds = YES;
        self.puFView.layer.cornerRadius = 10;
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 9, 26, 26)];
        imgView.image = [UIImage imageNamed:@"selectdPuFBark"];
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imgView.frame) + 10, 0, 200, 44)];
        titleLabel.text = @"浦发账户";
        self.puFButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.puFButton.frame = CGRectMake(ScreenW - 10 - 22 -40, 7, 30, 30);
        [self.puFButton setBackgroundImage:[UIImage imageNamed:@"icon_check_select"] forState:(UIControlStateNormal)];
        [self.puFButton addTarget:self action:@selector(puFaButtonAction) forControlEvents:(UIControlEventTouchUpInside)];
        [self.puFView addSubview:imgView];
        [self.puFView addSubview:titleLabel];
        [self.puFView addSubview:self.puFButton];
    }
    return _puFView;
}
- (UIView *)kuaiQView{
    if (!_kuaiQView) {
        self.kuaiQView = [[UIView alloc] initWithFrame:CGRectMake(15,CGRectGetMaxY(self.puFView.frame) + 10, ScreenW - 30, 44)];
        self.kuaiQView.backgroundColor = [UIColor whiteColor];
        self.kuaiQView.layer.masksToBounds = YES;
        self.kuaiQView.layer.cornerRadius = 10;
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 9, 26, 26)];
        imgView.image = [UIImage imageNamed:@"selectedBarkKuaiq"];
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imgView.frame) + 10, 0, 200, 44)];
        titleLabel.text = @"快钱账户";
        self.kuaiQButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.kuaiQButton.frame = CGRectMake(ScreenW - 10 - 22 -40, 7, 30, 30);
        [self.kuaiQButton setBackgroundImage:[UIImage imageNamed:@"icon_check"] forState:(UIControlStateNormal)];
        [self.kuaiQButton addTarget:self action:@selector(kuaiQianButtonAction) forControlEvents:(UIControlEventTouchUpInside)];
        [self.kuaiQView addSubview:imgView];
        [self.kuaiQView addSubview:titleLabel];
        [self.kuaiQView addSubview:self.kuaiQButton];
    }
    return _kuaiQView;
}
- (UIButton *)BangDingButton{
    if (!_BangDingButton) {
        self.BangDingButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.BangDingButton.frame = CGRectMake(15, CGRectGetMaxY(self.kuaiQView.frame) +  11, ScreenW - 30, 44);
        if ([self.bangdingStr isEqualToString:@"1"]) {
            self.BangDingButton.backgroundColor = Theme_ColorValue;
            [self.BangDingButton setTitle:@"绑定账户" forState:(UIControlStateNormal)];
        }else{
            self.BangDingButton.backgroundColor = [UIColor colorWithRed:255/255.0 green:144/255.0 blue:0/255.0 alpha:1];
            [self.BangDingButton setTitle:@"解绑账户" forState:(UIControlStateNormal)];
        }
        [self.BangDingButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        self.BangDingButton.layer.masksToBounds = YES;
        self.BangDingButton.layer.cornerRadius = 10;
        [self.BangDingButton addTarget:self action:@selector(bangdingAction) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _BangDingButton;
}
- (void)bangdingAction{
    self.blockSelectedStr(self.isPuFaBack);
}
- (void)puFaButtonAction{
    self.isPuFaBack = @"1";
    [self.puFButton setBackgroundImage:[UIImage imageNamed:@"icon_check_select"] forState:(UIControlStateNormal)];
    [self.kuaiQButton setBackgroundImage:[UIImage imageNamed:@"icon_check"] forState:(UIControlStateNormal)];

}
- (void)kuaiQianButtonAction{
    self.isPuFaBack = @"0";
    [self.puFButton setBackgroundImage:[UIImage imageNamed:@"icon_check"] forState:(UIControlStateNormal)];
    [self.kuaiQButton setBackgroundImage:[UIImage imageNamed:@"icon_check_select"] forState:(UIControlStateNormal)];
}
@end
